/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.uml_generator.model.impl;

import java.util.HashSet;
import java.util.Set;

import com.genia.toolbox.uml_generator.model.AbstractClassModel;
import com.genia.toolbox.uml_generator.model.AssociationModel;
import com.genia.toolbox.uml_generator.model.AttributeModel;

/**
 * this class represent the models entities from the xmi file.
 */
public abstract class AbstractClassModelImpl
    extends AbstractDelegatableObjectImpl
    implements AbstractClassModel
{

  /**
   * the class this one extends.
   */
  private AbstractClassModel parent = null;

  /**
   * the attributes to this class.
   */
  private final Set<AttributeModel> attributes = new HashSet<AttributeModel>();

  /**
   * the associations of this class.
   */
  private final Set<AssociationModel> associations = new HashSet<AssociationModel>();

  /**
   * the model of the implementation class.
   */
  private AbstractClassModel implementationModel;

  /**
   * whether this class is abstract.
   */
  private boolean abstractClass = false;



  /**
   * add an association to the class.
   * 
   * @param association
   *          the association to add
   * @see com.genia.toolbox.uml_generator.model.AbstractClassModel#addAssociation(com.genia.toolbox.uml_generator.model.AssociationModel)
   */
  public void addAssociation(final AssociationModel association)
  {
    this.associations.add(association);
  }



  /**
   * add an attribute to this class.
   * 
   * @param attribute
   *          the attribute to add
   * @see com.genia.toolbox.uml_generator.model.AbstractClassModel#addAttribute(com.genia.toolbox.uml_generator.model.AttributeModel)
   */
  public void addAttribute(final AttributeModel attribute)
  {
    this.attributes.add(attribute);
  }



  /**
   * returns the list of associations of this class.
   * 
   * @return the list of associations of this class
   * @see com.genia.toolbox.uml_generator.model.AbstractClassModel#getAssociations()
   */
  public Set<AssociationModel> getAssociations()
  {
    return associations;
  }



  /**
   * returns the list of attributes to this class.
   * 
   * @return the list of attributes to this class
   * @see com.genia.toolbox.uml_generator.model.AbstractClassModel#getAttributes()
   */
  public Set<AttributeModel> getAttributes()
  {
    return attributes;
  }



  /**
   * getter for parent property.
   * 
   * @return the parent
   */
  public AbstractClassModel getParent()
  {
    return parent;
  }



  /**
   * returns wether this object is an interface.
   * 
   * @return wether this object is an interface
   * @see com.genia.toolbox.uml_generator.model.AbstractClassModel#isInterface()
   */
  public abstract boolean isInterface();



  /**
   * setter for parent property.
   * 
   * @param parent
   *          the parent to set
   */
  public void setParent(AbstractClassModel parent)
  {
    this.parent = parent;
  }



  /**
   * returns the original object if the current object is decorated.
   * 
   * @return the original object if the current object is decorated
   */
  @Override
  public AbstractClassModel getUndecoraredObject()
  {
    return this;
  }



  /**
   * getter for the implementationModel property.
   * 
   * @return the implementationModel
   */
  public AbstractClassModel getImplementationModel()
  {
    return implementationModel;
  }



  /**
   * setter for the implementationModel property.
   * 
   * @param implementationModel
   *          the implementationModel to set
   */
  public void setImplementationModel(AbstractClassModel implementationModel)
  {
    this.implementationModel = implementationModel;
  }



  /**
   * getter for the abstractClass property.
   * 
   * @return the abstractClass
   */
  public boolean isAbstractClass()
  {
    return abstractClass;
  }



  /**
   * setter for the abstractClass property.
   * 
   * @param abstractClass
   *          the abstractClass to set
   */
  public void setAbstractClass(boolean abstractClass)
  {
    this.abstractClass = abstractClass;
  }

}
